﻿using System;

namespace Beefly.Json.Extensions;

static class BooleanExtension
{
    private const string TRUE = "true";
    private const string FALSE = "false";
    
    public static bool TryReadBooleanChar<TTarget>(in this Span<char> str, out TTarget value)
    {
        bool source = false;
        if (str == TRUE.AsSpan())
            source = true;
        else
            source = false;
        
        if (source is TTarget item)
        {
            value = item;
            return true;
        }

        value = default;
        return false;
    }
}